123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- "use server";
- import { BannerRep, GroupType, NoticeRep, PromotionRep } from "@/api/home";
- import Box from "@/components/Box";
- import HomeActions from "./_home/HomeActions";
- import HomeCard from "./_home/HomeCard";
- import HomeGames from "./_home/HomeGames";
- import HomeMessage from "./_home/HomeMessage";
- import HomeNoticeBar from "./_home/HomeNoticeBar";
- import HomePrize from "./_home/HomePrize";
- import HomePromotion from "./_home/HomePromotion";
- import HomeSearch from "./_home/HomeSearch";
- import HomeSwiper from "./_home/HomeSwiper";
- import HomeTabs from "./_home/HomeTabs";
- const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL;
- const TIME = 30;
- const getGames = async (): Promise<GroupType[]> => {
- try {
- const data = await fetch(`${BASE_URL}/v1/api/front/game_list`, {
- method: "POST",
- body: JSON.stringify({ template_key: "g_temp_9" }),
- next: { revalidate: TIME },
- }).then((res) => res.json());
- console.log(`🎯🎯🎯🎯🎯-> in page.tsx on 24`, data.data);
- return data.data;
- } catch (err) {
- return [];
- }
- };
- const getBanners = async (): Promise<BannerRep[]> => {
- try {
- const response = await fetch(`${BASE_URL}/v1/api/front/banner_list`, {
- method: "POST",
- body: JSON.stringify({}),
- headers: {
- language: "zh",
- },
- next: { revalidate: TIME },
- }).then((res) => res.json());
- return response.data;
- } catch (err) {
- return Promise.resolve([]);
- }
- };
- const getNotices = async (): Promise<NoticeRep[]> => {
- try {
- const response = await fetch(`${BASE_URL}/v1/api/front/marquee`, {
- method: "POST",
- body: JSON.stringify({}),
- headers: {
- language: "zh",
- },
- next: { revalidate: TIME },
- }).then((res) => res.json());
- return response.data;
- } catch (err) {
- return [];
- }
- };
- const getActivities = async (): Promise<BannerRep[]> => {
- try {
- const response = await fetch(`${BASE_URL}/v1/api/front/activity_home`, {
- method: "POST",
- body: JSON.stringify({}),
- headers: {
- language: "zh",
- },
- next: { revalidate: TIME },
- }).then((res) => res.json());
- return response.data;
- } catch (err) {
- return [];
- }
- };
- const getPromotions = async (): Promise<PromotionRep[]> => {
- try {
- const response = await fetch(`${BASE_URL}/v1/api/front/pop_list`, {
- method: "POST",
- body: JSON.stringify({}),
- headers: {
- language: "zh",
- },
- next: { revalidate: TIME },
- }).then((res) => res.json());
- return response.data;
- } catch (err) {
- return [];
- }
- };
- export default async function Page() {
- const [group = [], banners = [], notices = [], activities = [], promotions = []] =
- await Promise.all([
- getGames(),
- getBanners(),
- getNotices(),
- getActivities(),
- getPromotions(),
- ]);
- return (
- <div>
- <HomeMessage />
- <HomePromotion data={promotions} />
- <Box>
- <HomeSwiper banners={banners}></HomeSwiper>
- <HomeCard banners={activities}></HomeCard>
- <HomeNoticeBar notices={notices} />
- <HomeSearch />
- <HomePrize></HomePrize>
- <HomeTabs />
- </Box>
- {group.map((item) => {
- return <HomeGames groupGames={item.category} key={item.category_name} />;
- })}
- <Box>
- <HomeActions />
- </Box>
- </div>
- );
- }
|